package com.neusoft.javafeatures9.time;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * @author yabo
 */
public class TimeExample {
    public static void main(String[] args) {
//        System.out.println(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));;
//        System.out.println(DateUtil.format(new Date(), "yyyy-MM-dd'T'HH:mm:ssZ"));;//2022-08-23T15:15:10+0800、2022-08-23T07:17:26+0000
//        System.out.println(DateUtil.format(new Date(), "yyyy-MM-dd'T'HH:mm:ssz"));//2022-08-23T07:20:06GMT、2022-08-23T15:20:46CST
////        System.out.println(DateUtil.parse("2019-01-01T00:00:00Z", "yyyy-MM-dd'T'HH:mm:ssz"));;
//        System.out.println(DateUtil.parse("2022-08-23T15:10:05+0000", "yyyy-MM-dd'T'HH:mm:ssZ"));;
//        System.out.println(DateUtil.parse("2022-08-23T15:10:05UTC", "yyyy-MM-dd'T'HH:mm:ssZ"));;
//        System.out.println(DateUtil.parse("2022-08-23T15:10:05z", "yyyy-MM-dd'T'HH:mm:ssZ"));;
//        System.out.println(DateUtil.parse("2022-08-23T15:10:05z", "yyyy-MM-dd'T'HH:mm:ssz"));;

//        System.out.println(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS"));;
//
//        String dateTime1 = "2022-08-23T15:20:46UTC";
//        String dateTime1 = "2022-08-23T15:20:46 UTC";
//        String dateTime1 = "2022-08-23T15:20:46Z";
//        String dateTime1 = "2022-08-23T15:20:46+0000";
        String dateTime1 = "2022-08-23T15:20:46 +0800";
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        SimpleDateFormat defaultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date time = format.parse(dateTime1);
            String result = defaultFormat.format(time);
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
